﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QuanLyThongTinNhanKhau.GUI
{
    public partial class TachHoKhau : Form
    {
        GUI.HoKhau hoKhauGUI;
        static String maHoKhau;
        static String maNhanKhau;

        model.BO.TachHoKhauBO tachHoKhauBO;

        public TachHoKhau(GUI.HoKhau hoKhau, String maHK, String maNK)
        {
            hoKhauGUI = hoKhau;
            maHoKhau = maHK;
            maNhanKhau = maNK;
            InitializeComponent();
        }

        private void TachHoKhau_Load(object sender, EventArgs e)
        {
            tachHoKhauBO = new model.BO.TachHoKhauBO(this, hoKhauGUI);

            tachHoKhauBO.loadLeftField(maHoKhau, maNhanKhau);
            tachHoKhauBO.loadHoKhau(maHoKhau);

            cboSelectQHCH.SelectedIndex = 0;
        }

        private void btnHuy_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnFind_Click(object sender, EventArgs e)
        {
            tachHoKhauBO.btnTimKiem();
        }

        private void gridViewHoKhau_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            tbSelectTenChuHo.Text = gridViewHoKhau.GetRowCellValue(gridViewHoKhau.FocusedRowHandle, "TenChuHo").ToString();
            tbSelectMaHoKhau.Text = gridViewHoKhau.GetRowCellValue(gridViewHoKhau.FocusedRowHandle, "MaHoKhau").ToString();
        }

        private void btnLuu_Click(object sender, EventArgs e)
        {
            if ("".Equals(this.tbSelectMaHoKhau.Text))
            {
                MessageBox.Show("Bạn chưa chọn hộ khẩu cần chuyển đến");
            }
            else
            {
                tachHoKhauBO.btnLuu();
            }
        }

        private void cboSelectQHCH_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}
